/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.swosh.stomp.ejb;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;

/**
 * Instance slouzi k prenaseni atributu osob, ktere se registruji nebo chteji
 * byt registrovany.
 *
 * @author swosh
 */
@Entity
public class AppUser implements Serializable {

    @Id
    private String email;

    @Column(nullable = false)
    private String password;

    @Column(name = "akthash", nullable = false)
    private String aktHash;
    
    @ManyToMany(cascade=CascadeType.ALL)
    @JoinTable(name = "appuserrolepermission",
    joinColumns =
    @JoinColumn(name = "email"),
    inverseJoinColumns =
    @JoinColumn(name = "role"))
    private Collection<RolePermission> rolePermissions;

    public AppUser(String email, String password) {
        this.email = email;
        this.password = password;
    }

    public AppUser(String email) {
        this(email, null);
    }

    public AppUser() {
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getAktHash() {
        return aktHash;
    }

    public void setAktHash(String aktHash) {
        this.aktHash = aktHash;
    }

    public Collection<RolePermission> getRolePermissions(){
        return rolePermissions;
    }
    
    public void setRolePermissions(Collection<RolePermission> rolePermissions) {
        this.rolePermissions = rolePermissions;
    }
}
